angular.module("app").directive("appPayment", ["userInfo", "$rootScope", "$state", function(userInfo, $rootScope, $state) {

	return {
		restrict: 'AE',
		templateUrl: 'views/template/payment.html',
		replate: true,
		link: function(scope, ele, attr) {

			scope.bank_ico = "" //银行图标
			scope.bank_name = "" //银行名称
			scope.acc_number = "" //银行卡号
			scope.acc_amount = "" //钱包余额
			scope.simplet_date_amount=""//单笔最大限额
			scope.max_amount=""//单日限额
			if(userInfo.user_code) {
				userInfo.getUserBank().then(function(res) {
					scope.bank_ico = res.body.card.icon_url
					scope.bank_name = res.body.card.bank_name
					scope.acc_number = res.body.card.acc_number
					scope.acc_amount = res.body.card.acc_amount
					scope.simplet_date_amount=res.body.card.simplet_date_amount
					scope.max_amount=res.body.card.max_amount
				})
			}

			/*关闭弹窗*/
			mui(document).on("tap", "#dialog_close", function() {
				$rootScope.isShow = false
				$rootScope.$apply()
			})

			//银行卡支付
			mui(document).on("tap", "#yinhang", function() {
				$state.go("buy", {
					type: 1
				})
			})
			//钱包支付
			mui(document).on("tap", "#qianbao", function() {
				$state.go("buy", {
					type: 2
				})
			})

		}

	}

}])